import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getProperty } from "@/lib/queries"; import { dbAvailable } from "@/lib/db"; import { fmtPrice, fmtInt, fmtArea } from "@/lib/format"; import { CATEGORY_LABEL } from "@/lib/normalize"; import { ListingCardView } from "@/components/listing-card"; import { MapView } from "@/components/map-view"; import { Notice, Stat } from "@/components/ui"; export const dynamic = "force-dynamic"; type Props = { params: Promise<{ id: string }> }; export async function generateMetadata({ params }: Props): Promise { const { id } = await params; const p = dbAvailable() ? getProperty(id) : null; return { title: p ? `${p.address ?? "Propriété"}, ${p.city} — fiche propriété` : "Propriété", robots: { index: false } }; } export default async function Propriete({ params }: Props) { const { id } = await params; if (!dbAvailable()) notFound(); const p = getProperty(id); if (!p) notFound(); const sale = p.listings.filter((l) => l.market === "sale"); const rent = p.listings.filter((l) => l.market === "rent"); const byType = new Map(); for (const l of rent) { const k = l.typeLabel ?? "Logement"; byType.set(k, [...(byType.get(k) ?? []), l]); } return (

Fiche propriété canonique

{p.address ?? CATEGORY_LABEL[p.category ?? "autre"]}

{p.city}{p.region ? `, ${p.region}` : ""}

{p.role_value != null && } {(p.area_sqft || p.year_built) && }
Une propriété peut avoir plusieurs annonces (sources, unités, dates). Toveli les relie par {p.key_kind === "role" ? "l'unité du rôle d'évaluation (jumelage spatial ≤ 40 m)" : p.key_kind === "address" ? "une clé d'adresse normalisée (numéro civique + rue + municipalité)" : "une cellule de coordonnées (≈ 10 m)"} ; les unités en copropriété et les adresses ambiguës ne sont pas fusionnées automatiquement. {p.lat != null && p.lng != null &&
l.lat != null).slice(0, 1).map((l) => ({ uid: l.uid, lat: l.lat!, lng: l.lng!, price: l.price ?? 0 }))} center={[p.lat, p.lng]} zoom={15} />
} {sale.length > 0 &&

À vendre ({sale.length})

{sale.map((l) => )}
} {rent.length > 0 &&

À louer ({rent.length})

{[...byType.entries()].map(([t, ls]) =>

{t} · {ls.length}

{ls.slice(0, 12).map((l) => )}
{ls.length > 12 &&

+ {ls.length - 12} autres unités de ce type.

}
)}
}

← Retour à la recherche

); }